<template>
    <div>
        <list title="立即购买"/>
        <div class="wrap">
            <van-contact-card
                :type="ContactType"
                :name="orderContact.name"
                :tel="orderContact.tel"
                @click="onEdit"
            />
            <div class="items">
                <div class="item" v-for="i in currentOrder.items" :key="i.id">
                    <van-card
                        :num="i.num"
                        :price="i.minPrice"
                        :title="i.name"
                        :thumb="i.pic"
                    />
                </div>
            </div>

        </div>
        <van-submit-bar :price="currentOrder.total*100" button-text="提交订单" @submit="onSubmit" />
    </div>
</template>
<script>
import list from '@views/Home/component/ItemListHead'
import { mapState } from 'vuex'
import { Notify } from 'vant'

export default {
  methods: {
    onSubmit () {
      Notify('购买成功')
    },
    onEdit () {
      if (this.ContactType === 'edit') {
        this.$router.replace('./contactLists')
      }
    }
  },
  components: {
    list
  },
  computed: {
    ...mapState({
      currentOrder: state => state.order.currentOrder,
      orderContact: state => state.order.orderContact
    }),
    ContactType () {
      return this.orderContact ? 'edit' : 'add'
    }
  }
}
</script>

<style lang="scss" scoped>
.wrap{
    margin-top: 46px;
    margin-bottom: 50px;
}
</style>
